package com.jiepu.exercise.advanceed.chapter1.test3;

import com.jiepu.exercise.advanceed.chapter1.test3.inter.Alarm;
import com.jiepu.exercise.advanceed.chapter1.test3.inter.Door;
import com.jiepu.exercise.advanceed.chapter1.test3.inter.Lock;
import com.jiepu.exercise.advanceed.chapter1.test3.inter.Module;
import com.sun.org.apache.xpath.internal.operations.Mod;

/**
 * @Description:  Door 接口 类
 * @author: xinjie.txt
 * @date: 2020/7/14  12:09
 */
public class MainTest {
	public static void main(String[] args) {
		SecurityDoor securityDoor = new SecurityDoor();
		SlidingDoor slidingDoor = new SlidingDoor();
		Drawer drawer = new Drawer();
		AlarmClock alarmClock = new AlarmClock();
		SafeBox safeBox = new SafeBox();
		test(securityDoor, slidingDoor, drawer, alarmClock, safeBox);

	}

	public static void test(Module...modules) {
		for (int i = 0, len = modules.length; i < len; i++) {
			Module module = modules[i];
			if (module instanceof Door) {
				((Door) module).open();
				((Door) module).close();
			}
			if (module instanceof Lock) {
				((Lock) module).lock();
				((Lock) module).unlock();
			}
			if (module instanceof Alarm) {
				((Alarm) module).alarm();
			}
			System.out.println("-----------------");
		} // for

	}
}
